<?php
namespace Test;
//php中的一些常用数据结构
class DataStruct
{
    public static function stackTest()
    {
        echo "栈例子\n";
        echo "栈是一种先进后出的数据结构\n";
        $stack = new \SplStack();
        $stack->push("data1\n");
        $stack->push("data2\n");

        echo $stack->pop();
        echo $stack->pop();
    }
    public static function queueTest()
    {
        echo "队列例子\n";
        echo "队列是一种先进先出的数据结构\n";
        $stack = new \SplQueue();
        $stack->enqueue("data1\n");
        $stack->enqueue("data2\n");

        echo $stack->dequeue();
        echo $stack->dequeue();
    }
    public static function minHeapTest()
    {
        echo "最小堆例子\n";
        $stack = new \SplMinheap();
        $stack->insert("data1\n");
        $stack->insert("data2\n");

        echo $stack->extract();
        echo $stack->extract();
    }
    public static function fixedArrayTest(){
        echo "固定长度数组\n";
        $arr = new \SplFixedArray(10);
        $arr[0] = 10;
        $arr[9] = 1234;
        var_dump($arr);
    }
}
